package com.yc.http.tomcat.impl;

import com.yc.http.tomcat.HttpServletRequest;
import com.yc.http.tomcat.HttpServletResponse;
import com.yc.http.tomcat.ServletException;

import java.io.IOException;
import java.io.PrintWriter;

public class HelloServlet extends HttpServletImpl{

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        String name = request.getParameter("name");
        PrintWriter out = response.getWriter();
        response.setContentType("text/html;charset=utf-8");
        if(name == null) {
            out.println("<h1>hello world!</h1>");
        } else {
            out.println("<h1>hello "+name+"!</h1>");
        }
    }
}
